package org.dtrd.modules.service.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.dtrd.modules.service.entity.bean.ServiceListInfo;
import org.dtrd.modules.service.entity.bean.ServicePackageRelationInfo;
import org.dtrd.modules.service.entity.request.EditServiceRequest;

import java.util.Date;


/**
 * <p>
 * 服务包和服务套餐的关系
 * </p>
 *
 * @author QR
 * @since 2021-11-19 18:52:54
 */
@Data
@TableName("dtrd_rl_service_package")
public class DtrdRlServicePackage {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 服务包id
     */
    private Integer packageId;

    /**
     * 服务套餐id
     */
    private Integer serviceId;

    /**
     * 服务次数
     */
    @TableField(value = "service_count", updateStrategy = FieldStrategy.IGNORED)
    private Integer serviceCount;

    /**
     * 服务周期
     */
    @TableField(value = "service_month", updateStrategy = FieldStrategy.IGNORED)
    private String serviceMonth;

    /**
     * 判断是否属于服务包
     */
    private boolean flag;

    private Date createTime;

    private Date updateTime;

    private Integer isDel;

    public DtrdRlServicePackage init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }
    public DtrdRlServicePackage(){}

    public DtrdRlServicePackage(Integer packageId) {
        this.packageId = packageId;
    }

    public DtrdRlServicePackage parseFromDTO(ServiceListInfo dto) {
        serviceId = dto.getDataId();
        serviceCount = dto.getServiceCount();
        serviceMonth = dto.getServiceMonth();
        return this;
    }

    public DtrdRlServicePackage parseFromDTO(EditServiceRequest dto) {
        serviceId = dto.getDataId();
        serviceCount = dto.getServiceCount();
        serviceMonth = dto.getServiceMonth();
        flag = dto.isFlag();
        return this;
    }

    public DtrdRlServicePackage parseFromDTO(ServicePackageRelationInfo dto) {
        serviceId = dto.getServiceId();
        serviceCount = dto.getServiceCount();
        serviceMonth = dto.getServicePeriod();
        return this;
    }


}
